from bson import ObjectId
from pymongo import MongoClient


host = '127.0.0.1'
port = 27017
dbname = 'arvin_disk'
def_dbname = 'test'


def get_database(name=def_dbname):
    """ 获取MongoDB数据库对象 """
    mongo = MongoClient(host=host, port=port)
    return mongo.get_database(name)


def get_collection(collect_name, database=get_database(dbname)):
    """ 获取MongoDB集合对象 """
    return database.get_collection(name=collect_name)


def get_hex_objectid():
    """ 获取MongoDB的ObjectId哈希字符串 """
    return str(ObjectId())

